Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 2 - Geometric Shapes / About Geometric Shapes


The Geometric Properties of Shape Objects

Every shape object has three geometric properties: the shape type, the shape geometry, and the shape fill. For geometric shapes, these properties define

The next three sections examine these properties in more detail.

Shape Type

The shape type property of a shape object specifies what type of shape the shape object represents. There are thirteen different QuickDraw GX shape types: one for bitmap shapes, one for picture shapes, three for typographic shapes, and eight for geometric shapes. The eight geometric shape types are:

The value of the shape type property affects the way QuickDraw GX interprets the other properties of the shape. In particular, different types of shapes store substantially different information in their geometry properties. For example, the geometry of a point shape contains only an x-coordinate and a y-coordinate. The geometry of a line contains an x-coordinate and a y-coordinate to define the beginning of the line and an x-coordinate and a y-coordinate to define the end of the line. The geometry of a polygon shape can contain many pairs of (x, y) coordinates.

Figure 2-2 shows a shape object and lists six possible values for its shape type property. This figure also shows a sample geometry for each of the shape types listed. Each geometry is made up of geometric points (specified by (x, y) coordinate pairs) and edges connecting the geometric points. The next section, "Shape Geometry," discusses geometric points and edges in more detail.

Figure 2-2 The geometric shape types and examples of geometric shape geometries

There are two types of geometric shapes not shown in this figure: the empty shape and the full shape. An empty shape is a shape that has no geometry and covers no area. A full shape is the inverse of an empty shape--it covers all area. You can find more information about these shape types in "Empty Shapes and Full Shapes" beginning on page 2-16.

Shape Geometry

Each type of geometric shape uses the geometry property of its shape object in a slightly different manner. For example, empty shapes and full shapes store no information in their geometry, because they require no further geometric information--their shape type says it all.

However, for other types of geometric shapes, the shape type does not contain all the geometric information necessary to define the shape. The geometries of these shapes contain (x, y) coordinate pairs called geometric points--points that specify the location, dimension, and form of the geometric shapes:

Figure 2-3 shows a polygon shape with a two polygon contours made up of seven geometric points total. This figure shows two views of the polygon geometry: as a list of (x, y) coordinate pairs and as seven geometric points plotted on a geometric grid. This second way of viewing geometries is used frequently throughout this book, as it shows not only the geometric points, but also the implied edges that connect them. Typically, the figures in this book do not show the grid, but just the points and edges.

Figure 2-3 A polygon shape with a single contour containing three geometric points

Each geometric point in a geometry has a geometry index--if you consider the geometry as a list of geometric points starting from the first geometric point of the first contour to the last geometric point of the last contour, the geometry index of a particular geometric point is its position in this list. For example, in the shape in Figure 2-3, the first point (0.0, 100.0) has a geometry index of 1, the second point (50.0, 0.0) has a geometry index of 2, and the third point (100.0, 100.0) has a geometry index of 3. The first point in the second contour (0.0, 150.0) has a geometry index of 4, as it is the fourth geometric point in the geometry. However, it has a contour index of 1, as it is the first point of its contour. Similarly, the next point (100.0, 150.0) has a geometry index of 5 and a contour index of 2, and so forth.

Notice that each of the three edges of the polygon contour in Figure 2-3 has a direction. The first edge is pointing up and to the right; the second edge is pointing down and to the right; the third edge is pointing to the left. QuickDraw GX takes into consideration the direction that an edge is pointing in a number of circumstances:

QuickDraw GX uses contour direction and the inside and outside of a shape when applying certain stylistic variations, as described in Chapter 3, "Geometric Styles," and when performing certain geometric operations, as described in Chapter 4, "Geometric Operations," of this book.

For more details about the geometries of the various geometric shapes, see "The Geometric Shape Types" beginning on page 2-16.

Shape Fill

The shape fill property specifies how QuickDraw GX interprets the geometric points of a geometric shape's geometry during drawing and other operations. There are two basic types of shape fills:

Figure 2-4 shows an example of a polygon contour similar to the one in Figure 2-3, and how QuickDraw GX might draw it with a framed fill and with a solid fill.

Figure 2-4 Framed shapes versus solid shapes

QuickDraw GX actually provides seven types of shape fills:

Figure 2-5 shows these shape fills and the effect they have on three sample geometries.

Figure 2-5 The various shape fills and examples of their effects

The no-fill shape fill specifies that QuickDraw GX should not draw the shape. You can use this shape fill to hide a shape. You can specify the no-fill shape fill for any shape type.

The open-frame shape fill specifies that QuickDraw GX should draw a shape as a connected set of edges. The closed-frame shape fill indicates that QuickDraw GX should also connect the last geometric point of a contour to the first geometric point of that contour.

The even-odd shape fill and the winding shape fill indicate that QuickDraw GX should interpret the shape as a solid area--the edges of the shape represent the boundaries of the area. These two shape fills differ in the algorithm they use to determine what area to include in the shape.

The even-odd shape fill indicates that QuickDraw GX should use the even-odd rule to determine what area lies inside a shape. As QuickDraw GX scans a shape horizontally, it fills the area between every other pair of edges, as shown in Figure 2-6.

The winding shape fill indicates that QuickDraw GX should use the winding-number rule to determine what area lies inside a shape. As QuickDraw GX scans a shape horizontally, it increments a counter the first time it crosses an edge of the shape. It also notices whether the contour was directed up or down at that edge. As QuickDraw GX continues to scan the shape horizontally, everytime it crosses another edge pointed in the same direction (up or down), it increments the counter, and when it crosses an edge pointing in the opposite direction (down or up), it decrements the counter. Wherever along the horizontal scan line the counter is not zero, QuickDraw GX fills the area, as is shown in Figure 2-6.

Figure 2-6 The even-odd rule and winding-number rule algorithms

The inverse even-odd shape fill indicates the inverse of the even-odd shape fill, as shown in Figure 2-7.

Figure 2-7 The inverse even-odd shape fill

Similarly, the inverse winding shape fill indicates the inverse of the winding shape fill.

Not all shape fills are appropriate for all types of geometric shapes. For example, a rectangle shape can have a closed-frame shape fill but not an open-frame shape fill; a line shape can only have an no-fill or an open-frame shape fill.

See the sections on each shape type, beginning on page 2-16, for a complete discussion of the shape fills that are allowed for each shape type.

The shape fill does more than affect the way a shape is drawn; it affects the fundamental behavior of a shape. Two shapes with the same geometry that have different shape fills can exhibit vastly different geometric behaviors. For example, the shape fill can affect

For examples of how shape fill affects the behavior of shapes, see


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help